<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="lib.db.admin.*"%>
<jsp:useBean id="bdAdminDAO" class="lib.db.admin.AdminDAO" scope="session"/>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK href="../include/default.css" type="text/css" rel="stylesheet">
<SCRIPT src="../include/default.js" type="text/javascript"></SCRIPT>
<title>ADMIN:EDIT:RESP</title>
</head>

<body>
<%@ include file="../include/header.jsp" %>
<br>

<%
    request.setCharacterEncoding("UTF-8");
    String sAdminId   = request.getParameter("id");
    String sCurrStatus= request.getParameter("currStatus");
    if (sAdminId == null || sCurrStatus == null) {
    	return;
    }

    int newStatus;
    if ("1".equals(sCurrStatus.trim())) {
    	newStatus = 0;
    } else if ("0".equals(sCurrStatus.trim())) {
    	newStatus = 1;
    } else {
	return;
    }


    String inform = "";
    String lockOrUnlock = (newStatus == 1) ? "UnLock": "Lock";
    boolean isOK = bdAdminDAO.updateStatus(new BigDecimal(sAdminId.trim()), newStatus);
    if (isOK) {
    	inform = "YES, " + lockOrUnlock + " admin account successfully!";
    } else {
    	inform = "SORRY, " + lockOrUnlock + " admin account failt!";
    }

    String sRef = "list.jsp";
    String sHeader = "OK";
    if (!isOK) {
            sRef = "javascript:history.go(-1);";
            sHeader = "ERROR";
    }
%>
<%@ include file="../include/msg_box.jsp" %>

</body>
</html>
